package algorithm.test;

public class Choose {

    public static void choose(Comparable[] a){
        for (int i=0;i<a.length;i++){
            int max=i;
            for (int j=i+1;j<a.length;j++){
                if (greater(a[max],a[j])){
                    max=j;
                }
            }
            exch(a,i,max);
        }
        for (int i=0;i<a.length;i++) {
            System.out.println(a[i]);
        }
    }
    public static boolean greater(Comparable v,Comparable w){
        return v.compareTo(w)>0;
        //v是否大于w
    }

    private static void exch(Comparable[] a,int i,int j){
        Comparable t=a[i];
        a[i]=a[j];
        a[j]=t;
    }
}
